// let User = require("./../../CClass/class/User");
let runGame = require("./runGame");
let baccaratUser = require("./baccaratUser");
let baccaratQZUser = require("./baccaratQZUser");
// let caidaxiaoUser = require("./caidaxiaoUser");
let landlordUser = require("./landlordUser");
let longhudouUser = require("./longhudouUser");
// let qiangcowUser = require("./qiangcowUser");s
// let GoldenFlower = require("./goldenFlower");
// let bairen_niuniuUser = require("./bairen_niuniuUser");
let Holdem = require("./holdem");
let FishUser = require("./fishserver_haiwang2User");
let bcbmUser = require("./bcbmUser");
// let tiequan6User = require("./tiequan6User");
// let dznzUser = require("./dznzUser");
// let ttzUser = require("./ttzUser");
let ColorUser = require("./1014_ColorUser");
let feiqinzoushouUser = require("./1015_feiqinzoushouUser");
let fanyingbiUser = require("./1016_fanyingbiUser");
// let hongheidazhanUser = require("./1018_hongheidazhanUser");
// let douniuUser = require("./1019_douniuUser");
let shenshouUser = require("./1020_shenshouUser");
let UpDown7User = require("./1024_7UpDownUser");
let schedule = require("node-schedule");
let gameConfig = require("./../config/gameConfig");
let log = require("./../../util/loginfo").getInstand;

var robotInfo = function () {

    var _gameinfo = "";

    var Game = function () {

        //初始化游戏
        this.init = function (_config) {
            log.info('####init robot!####');
            this.timer = 0;
            this.MatchFishRobotList = {};
            this.FishRobotList = {};
            this.Game28RobotList = {};
            this.redbagRobotList = {};
            this.jia82RobotList = {};
            // this.cowRobotList = {};
            // this.qiangcowRobotList_1 = {};
            // this.qiangcowRobotList_2 = {};
            // this.qiangcowRobotList_3 = {};
            // this.qiangcowRobotList_4 = {};
            // this.jingdiancowRobotList = {};
            // this.landlordRobotList_1 = {};
            // this.landlordRobotList_2 = {};
            // this.landlordRobotList_3 = {};
            // this.landlordRobotList_4 = {};
            this.longhuRobotList = {};
            this.baccaratRobotList = {};
            this.baccaratQZRobotList = {};
            this.caidaxiaoRobotList = {};
            this.bairenniuniuRobotList = {};
            this.ColorRobotList = {};
            this.feiqinzoushouRobotList = {};
            this.fanyingbiRobotList = {};
            this.hongheidazhanRobotList = {};
            this.douniuRobotList = {};
            this.shenshouRobotList = {};
            this.upDown7RobotList = {};
            this.runRobotList_1 = {};
            this.runRobotList_2 = {};
            this.runRobotList_3 = {};
            this.runRobotList_4 = {};
            this.goldenFowerRobotList_1 = {};
            this.goldenFowerRobotList_2 = {};
            this.goldenFowerRobotList_3 = {};
            this.goldenFowerRobotList_4 = {};
            this.holdemRobotList_1 = {};
            this.holdemRobotList_2 = {};
            this.holdemRobotList_3 = {};
            this.holdemRobotList_4 = {};
            this.bcbmRobotList = {};
			this.tiequan6RobotList = {};
            this.dznzRobotList = {};
            this.MatchMin = 6;
            this.MatchMax = 10;
            //最大人数

            this.MatchFishRobotMax = Math.floor(Math.random() * 10) + 5;
            this.FishRobotMax = 3;
            this.Game28RobotMin_c = 5;
            this.Game28RobotMax_c = 10;
            this.Game28RobotMax = 10;

            this.redbagRobotMin_c = 5;
            this.redbagRobotMax_c = 10;
            this.redbagRobotMax = 10;

            this.jia82RobotMin_c = 5;
            this.jia82RobotMax_c = 10;
            this.jia82RobotMax = 10;

            this.cowRobotMin_c = 5;
            this.cowRobotMax_c = 10;
            this.cowRobotMax = 10;

            this.qiangcowRobotMin_c = 5;
            this.qiangcowRobotMax_c = 10;
            this.qiangcowRobotMax = 10;

            this.jingdiancowRobotMin_c = 5;
            this.jingdiancowRobotMax_c = 10;
            this.jingdiancowRobotMax = 10;

            this.landlordRobotMin_c = 5;
            this.landlordRobotMax_c = 10;
            this.landlordRobotMax = 10;


            this.runRobotMin_c = 5;
            this.runRobotMax_c = 10;
            this.runRobotMax = 10;

            this.goldenFowerRobotMin_c = 5;
            this.goldenFowerRobotMax_c = 10;
            this.goldenFowerRobotMax = 10;

            this.holdemRobotMin_c = 5;
            this.holdemRobotMax_c = 10;
            this.holdemRobotMax = 10;

            this.MatchFishRobotCount = 0;
            this.FishRobotCount = 0;
            this.Game28RobotCount = 0;
            this.redbagRobotCount = 0;
            this.jia82RobotCount = 0;
            this.cowRobotCount = 0;
            this.qiangcowRobotCount_1 = 0;
            this.qiangcowRobotCount_2 = 0;
            this.qiangcowRobotCount_3 = 0;
            this.qiangcowRobotCount_4 = 0;
            this.jingdiancowRobotCount = 0;
            this.landlordRobotCount_1 = 0;
            this.landlordRobotCount_2 = 0;
            this.landlordRobotCount_3 = 0;
            this.landlordRobotCount_4 = 0;
            this.longhuRobotCount = 0;
            this.baccaratRobotCount = 0;
            this.baccaratQZRobotCount = 0;
            this.caidaxiaoRobotCount = 0;
            this.bairenniuniuRobotCount = 0;
            this.ColorRobotCount = 0;
            this.feiqinzoushouRobotCount = 0;
            this.fanyingbiRobotCount = 0;
            this.hongheidazhanRobotCount = 0;
            this.douniuRobotCount = 0;
            this.shenshouRobotCount = 0;
            this.upDown7RobotCount = 0;
            this.runRobotCount_1 = 0;
            this.runRobotCount_2 = 0;
            this.runRobotCount_3 = 0;
            this.runRobotCount_4 = 0;
            this.goldenFowerRobotCount_1 = 0;
            this.goldenFowerRobotCount_2 = 0;
            this.goldenFowerRobotCount_3 = 0;
            this.goldenFowerRobotCount_4 = 0;
            this.holdemRobotCount_1 = 0;
            this.holdemRobotCount_2 = 0;
            this.holdemRobotCount_3 = 0;
            this.holdemRobotCount_4 = 0;
            this.bcbmRobotCount = 0;
			this.tiequan6RobotCount = 0;
            this.dznzRobotCount = 0;

            this.xuniwin = 0;

            this.fishIdx = 0;
            this.fishIdxMax = 4;
            this.Game28Idx = 0;
            this.Game28IdxMax = 4;
            this.jia82Idx = 0;
            this.jia82IdxMax = 4;
            this.qiangcowIdx = 0;
            this.qiangcowIdxMax = 4;
            this.jingdiancowIdx = 0;
            this.jingdiancowIdxMax = 4;

            this.landlordIdxMax = 1;

            this.longhuIdx = 0;
            this.baccaratIdx = 0;
            this.baccaratQZIdx = 0;
            this.caidaxiaoIdx = 0;
            this.bairenniuniuIdx = 0;
            this.ColorIdx = 0;
            this.feiqinzoushouIdx = 0;
            this.fanyingbiIdx = 0;
            this.hongheidazhanIdx = 0;
            this.douniuIdx = 0;
            this.shenshouIdx = 0;
            this.upDown7Idx = 0;

            this.runIdx = 0;
            this.runIdxMax = 4;
            this.goldenFowerIdx = 0;
            this.goldenFowerIdxMax = 4;
            this.holdemIdx = 0;
            this.holdemIdxMax = 4;
            this.bcbmIdx = 0;
			this.tiequan6Idx = 0;
            this.dznzIdx = 0;

            var info = {};
            info.FishRobot = 10;
            info.FishMatchRobotMin = 5;
            info.FishMatchRobotMax = 10;
            info.qiangcowRobotMin = 5;
            info.qiangcowRobotMax = 10;
            info.landlordRobotMin = 5;
            info.landlordRobotMax = 20;
            info.longhuRobotMin = 5;
            info.longhuRobotMax = 10;
            info.baccaratRobotMin = 5;
            info.baccaratRobotMax = 10;
            info.baccaratQZRobotMin = 5;
            info.baccaratQZRobotMax = 10;
            info.caidaxiaoRobotMin = 5;
            info.caidaxiaoRobotMax = 10;
            info.bairenniuniuRobotMin = 5;
            info.bairenniuniuRobotMax = 10;
            info.ColorRobotMin = 5;
            info.ColorRobotMax = 10;
            info.feiqinzoushouRobotMin = 5;
            info.feiqinzoushouRobotMax = 10;
            info.fanyingbiRobotMin = 5;
            info.fanyingbiRobotMax = 10;
            info.hongheidazhanRobotMin = 5;
            info.hongheidazhanRobotMax = 10;
            info.douniuRobotMin = 5;
            info.douniuRobotMax = 10;
            info.shenshouRobotMin = 5;
            info.shenshouRobotMax = 10;
            info.upDown7RobotMin = 5;
            info.upDown7RobotMax = 10;
            info.runRobotMin = 5;
            info.runRobotMax = 10;
            info.goldenFowerRobotMin = 5;
            info.goldenFowerRobotMax = 10;
            info.holdemRobotMin = 5;
            info.holdemRobotMax = 10;
            info.bcbmRobotMin = 5;
            info.bcbmRobotMax = 10;
			info.tiequan6RobotMin = 5;
            info.tiequan6RobotMax = 10;
            info.dznzRobotMin = 5;
            info.dznzRobotMax = 10;

            this.timetest(info);


            var rule = new schedule.RecurrenceRule();
            var times = [];
            for (var i = 0; i < 60; i++) {
                times.push(i);
            }
            rule.second = times;
            var c = 0;
            var self = this;
            var j = schedule.scheduleJob(rule, function () {

                if (gameConfig.maintain) {
                    --gameConfig.maintainTime;
                    ////log.info(gameConfig.maintainTime);;
                    if (!gameConfig.maintainTime) {
                        self.disconnectAllUser();
                    }
                }

                var nowDate = new Date();
                var minute = nowDate.getMinutes();
                var second = nowDate.getSeconds();


                if (minute % 5 == 0 && second == 1) {
                    // self.timetest(info);
                }

            });

        };


        this.timetest = function (info) {
            log.info("进入开始!");
            this.MatchMin = info.FishMatchRobotMin;
            this.MatchMax = info.FishMatchRobotMax - info.FishMatchRobotMin;
            this.MatchFishRobotMax = Math.floor(Math.random() * this.MatchMax) + this.MatchMin;
            this.FishRobotMax = info.FishRobot;
            this.Game28RobotMax = Math.floor(Math.random() * this.Game28RobotMax_c) + this.Game28RobotMin_c;


            this.qiangcowRobotMin_c = info.qiangcowRobotMin;
            this.qiangcowRobotMax_c = info.qiangcowRobotMax - info.qiangcowRobotMin;
            this.qiangcowRobotMax = Math.floor(Math.random() * this.qiangcowRobotMax_c) + this.qiangcowRobotMin_c;

            this.jingdiancowRobotMin_c = info.jingdiancowRobotMin;
            this.jingdiancowRobotMax_c = info.jingdiancowRobotMax - info.jingdiancowRobotMin;
            this.jingdiancowRobotMax = Math.floor(Math.random() * this.jingdiancowRobotMax_c) + this.jingdiancowRobotMin_c;

            this.landlordRobotMin_c = info.landlordRobotMin;
            this.landlordRobotMax_c = info.landlordRobotMax - info.landlordRobotMin;
            this.landlordRobotMax = Math.floor(Math.random() * this.landlordRobotMax_c) + this.landlordRobotMin_c;

            this.longhuRobotMin_c = info.longhuRobotMin;
            this.longhuRobotMax_c = info.longhuRobotMax - info.longhuRobotMin;
            this.longhuRobotMax = Math.floor(Math.random() * this.longhuRobotMax_c) + this.longhuRobotMin_c;

            this.baccaratRobotMin_c = info.baccaratRobotMin;
            this.baccaratRobotMax_c = info.baccaratRobotMax - info.baccaratRobotMin;
            this.baccaratRobotMax = Math.floor(Math.random() * this.baccaratRobotMax_c) + this.baccaratRobotMin_c;

            this.baccaratQZRobotMin_c = info.baccaratQZRobotMin;
            this.baccaratQZRobotMax_c = info.baccaratQZRobotMax - info.baccaratQZRobotMin;
            this.baccaratQZRobotMax = Math.floor(Math.random() * this.baccaratQZRobotMax_c) + this.baccaratQZRobotMin_c;

            this.caidaxiaoRobotMin_c = info.caidaxiaoRobotMin;
            this.caidaxiaoRobotMax_c = info.caidaxiaoRobotMax - info.caidaxiaoRobotMin;
            this.caidaxiaoRobotMax = Math.floor(Math.random() * this.caidaxiaoRobotMax_c) + this.caidaxiaoRobotMin_c;

            this.bairenniuniuRobotMin_c = info.bairenniuniuRobotMin;
            this.bairenniuniuRobotMax_c = info.bairenniuniuRobotMax - info.bairenniuniuRobotMin;
            this.bairenniuniuRobotMax = Math.floor(Math.random() * this.bairenniuniuRobotMax_c) + this.bairenniuniuRobotMin_c;

            this.ColorRobotMin_c = info.ColorRobotMin;
            this.ColorRobotMax_c = info.ColorRobotMax - info.ColorRobotMin;
            this.ColorRobotMax = Math.floor(Math.random() * this.ColorRobotMax_c) + this.ColorRobotMin_c;

            this.feiqinzoushouRobotMin_c = info.feiqinzoushouRobotMin;
            this.feiqinzoushouRobotMax_c = info.feiqinzoushouRobotMax - info.feiqinzoushouRobotMin;
            this.feiqinzoushouRobotMax = Math.floor(Math.random() * this.feiqinzoushouRobotMax_c) + this.feiqinzoushouRobotMin_c;

            this.fanyingbiRobotMin_c = info.fanyingbiRobotMin;
            this.fanyingbiRobotMax_c = info.fanyingbiRobotMax - info.fanyingbiRobotMin;
            this.fanyingbiRobotMax = Math.floor(Math.random() * this.fanyingbiRobotMax_c) + this.fanyingbiRobotMin_c;

            this.hongheidazhanRobotMin_c = info.hongheidazhanRobotMin;
            this.hongheidazhanRobotMax_c = info.hongheidazhanRobotMax - info.hongheidazhanRobotMin;
            this.hongheidazhanRobotMax = Math.floor(Math.random() * this.hongheidazhanRobotMax_c) + this.hongheidazhanRobotMin_c;

            this.douniuRobotMin_c = info.douniuRobotMin;
            this.douniuRobotMax_c = info.douniuRobotMax - info.douniuRobotMin;
            this.douniuRobotMax = Math.floor(Math.random() * this.douniuRobotMax_c) + this.douniuRobotMin_c;

            this.shenshouRobotMin_c = info.shenshouRobotMin;
            this.shenshouRobotMax_c = info.shenshouRobotMax - info.shenshouRobotMin;
            this.shenshouRobotMax = Math.floor(Math.random() * this.shenshouRobotMax_c) + this.shenshouRobotMin_c;

            this.upDown7RobotMin_c = info.upDown7RobotMin;
            this.upDown7RobotMax_c = info.upDown7RobotMax - info.upDown7RobotMin;
            this.upDown7RobotMax = Math.floor(Math.random() * this.upDown7RobotMax_c) + this.upDown7RobotMin_c;

            this.runRobotMin_c = info.runRobotMin;
            this.runRobotMax_c = info.runRobotMax - info.runRobotMin;
            this.runRobotMax = Math.floor(Math.random() * this.runRobotMax_c) + this.runRobotMin_c;

            this.goldenFowerRobotMin_c = info.goldenFowerRobotMin;
            this.goldenFowerRobotMax_c = info.goldenFowerRobotMax - info.goldenFowerRobotMin;
            this.goldenFowerRobotMax = Math.floor(Math.random() * this.goldenFowerRobotMax_c) + this.goldenFowerRobotMin_c;

            this.holdemRobotMin_c = info.holdemRobotMin;
            this.holdemRobotMax_c = info.holdemRobotMax - info.holdemRobotMin;
            this.holdemRobotMax = Math.floor(Math.random() * this.holdemRobotMax_c) + this.holdemRobotMin_c;

            this.bcbmRobotMin_c = info.bcbmRobotMin;
            this.bcbmRobotMax_c = info.bcbmRobotMax - info.bcbmRobotMin;
            this.bcbmRobotMax = Math.floor(Math.random() * this.bcbmRobotMax_c) + this.bcbmRobotMin_c;
			
			this.tiequan6RobotMin_c = info.tiequan6RobotMin;
            this.tiequan6RobotMax_c = info.tiequan6RobotMax - info.tiequan6RobotMin;
            this.tiequan6RobotMax = Math.floor(Math.random() * this.tiequan6RobotMax_c) + this.tiequan6RobotMin_c;

            this.dznzRobotMin_c = info.dznzRobotMin;
            this.dznzRobotMax_c = info.dznzRobotMax - info.dznzRobotMin;
            this.dznzRobotMax = Math.floor(Math.random() * this.dznzRobotMax_c) + this.dznzRobotMin_c;

            setInterval(this.time.bind(this), 10000);
        };

        this.time = function () {

            //普通房间机器人
            for (var item in this.FishRobotList) {
                if (!this.FishRobotList[item].isOnline()) {
                    this.FishRobotList[item].disconnect();
                    delete this.FishRobotList[item];
                    --this.FishRobotCount;
                }
            }

            if (this.FishRobotCount < this.FishRobotMax) {
                var idx = this.getNullRobotIdx();
                if (!this.FishRobotList[idx]) {
                    var account = "robot" + idx;
                    var userInfo = {account: account, robotMatch: false, idx: this.fishIdx};
                    var Robot = new FishUser(userInfo);
                    this.FishRobotList[idx] = Robot;
                    ++this.FishRobotCount;
                    ++this.fishIdx;
                    this.fishIdx = this.fishIdx % this.fishIdxMax;
                }
            }
            
            //28游戏机器人
            // for(var item in this.Game28RobotList){
            // 	if (!this.Game28RobotList[item].isOnline()){
            // 		this.Game28RobotList[item].disconnect();
            // 		this.xuniwin += this.Game28RobotList[item].win;
            // 		//log.info("累计虚拟获得:" + this.xuniwin);
            // 		delete this.Game28RobotList[item];
            // 		--this.Game28RobotCount;
            // 	}
            // }
            
            // if (this.Game28RobotCount < this.Game28RobotMax){
            // 	this.Game28RobotMax = Math.floor(Math.random()*this.Game28RobotMax_c) + this.Game28RobotMin_c;
            // 	var idx = this.getNullRobotIdx();
            //  	if (!this.Game28RobotList[idx]){
            //  		////log.info(idx + "进入28房间");
            //  		var account = "robot" + idx;
            // 		var userInfo = {account:account,robotMatch:false,idx:this.Game28Idx};
            // 		var Robot = new game28User(userInfo);
            // 		this.Game28RobotList[idx] = Robot;
            // 		++this.Game28RobotCount;
            // 		++this.Game28Idx;
            // 		this.Game28Idx = this.Game28Idx % this.Game28IdxMax;
            //  	}
            // }
            
            //红包机器人
            // for(var item in this.redbagRobotList){
            // 	if (!this.redbagRobotList[item].isOnline()){
            // 		this.redbagRobotList[item].disconnect();
            // 		delete this.redbagRobotList[item];
            // 		--this.redbagRobotCount;
            // 	}
            // }
            
            // if (this.redbagRobotCount < this.redbagRobotMax){
            // 	this.redbagRobotMax = Math.floor(Math.random()*this.redbagRobotMax_c) + this.redbagRobotMin_c;
            // 	var idx = this.getNullRobotIdx();
            //  	if (!this.redbagRobotList[idx]){
            //  		////log.info(idx + "进入28房间");
            //  		var account = "robot" + idx;
            // 		var userInfo = {account:account,robotMatch:false};
            // 		var Robot = new redbagUser(userInfo);
            // 		this.redbagRobotList[idx] = Robot;
            // 		++this.redbagRobotCount;
            //  	}
            // }
            
            //82jia机器人
            // for(var item in this.jia82RobotList){
            // 	if (!this.jia82RobotList[item].isOnline()){
            // 		this.jia82RobotList[item].disconnect();
            // 		delete this.jia82RobotList[item];
            // 		--this.jia82RobotCount;
            // 	}
            // }
            
            // if (this.jia82RobotCount < this.jia82RobotMax){
            // 	this.jia82RobotMax = Math.floor(Math.random()*this.jia82RobotMax_c) + this.jia82RobotMin_c;
            // 	var idx = this.getNullRobotIdx();
            //  	if (!this.jia82RobotList[idx]){
            //  		var account = "robot" + idx;
            // 		var userInfo = {account:account,robotMatch:false,idx:this.jia82Idx};
            // 		var Robot = new jia82User(userInfo);
            // 		this.jia82RobotList[idx] = Robot;
            // 		++this.jia82RobotCount;
            // 		++this.jia82Idx;
            // 		this.jia82Idx = this.jia82Idx % this.jia82IdxMax;
            //  	}
            // }
            
            //牛牛机器人
            // for(var item in this.cowRobotList){
            // 	if (!this.cowRobotList[item].isOnline()){
            // 		this.cowRobotList[item].disconnect();
            // 		delete this.cowRobotList[item];
            // 		--this.cowRobotCount;
            // 	}
            // }
            
            // if (this.cowRobotCount < this.cowRobotMax){
            // 	this.cowRobotMax = Math.floor(Math.random()*this.cowRobotMax_c) + this.cowRobotMin_c;
            // 	var idx = this.getNullRobotIdx();
            //  	if (!this.cowRobotList[idx]){
            //  		var account = "robot" + idx;
            // 		var userInfo = {account:account,robotMatch:false};
            // 		var Robot = new cowUser(userInfo);
            // 		this.cowRobotList[idx] = Robot;
            // 		++this.cowRobotCount;
            //  	}
            // }


            //经典牛牛机器人
            // for(var item in this.jingdiancowRobotList){
            // 	if (!this.jingdiancowRobotList[item].isOnline()){
            // 		this.jingdiancowRobotList[item].disconnect();
            // 		delete this.jingdiancowRobotList[item];
            // 		--this.jingdiancowRobotCount;
            // 	}
            // }
            
            // if (this.jingdiancowRobotCount < this.jingdiancowRobotMax){
            // 	this.jingdiancowRobotMax = Math.floor(Math.random()*this.jingdiancowRobotMax_c) + this.jingdiancowRobotMin_c;
            // 	var idx = this.getNullRobotIdx();
            //  	if (!this.jingdiancowRobotList[idx]){
            //  		var account = "robot" + idx;
            // 		var userInfo = {account:account,robotMatch:false,idx:this.jingdiancowIdx};
            // 		var Robot = new jingdiancowUser(userInfo);
            // 		this.jingdiancowRobotList[idx] = Robot;
            // 		++this.jingdiancowRobotCount;
            // 		++this.jingdiancowIdx;
            // 		this.jingdiancowIdx = this.jingdiancowIdx % this.jingdiancowIdxMax;
            //  	}
            // }


            //抢庄牛牛机器人     1
            // for (var item in this.qiangcowRobotList_1) {
            //     if (!this.qiangcowRobotList_1[item].isOnline()) {
            //         this.qiangcowRobotList_1[item].disconnect();
            //         delete this.qiangcowRobotList_1[item];
            //         --this.qiangcowRobotCount_1;
            //     }
            // }

            // if (this.qiangcowRobotCount_1 < 10) {
            //     this.qiangcowRobotMax = Math.floor(Math.random() * this.qiangcowRobotMax_c) + this.qiangcowRobotMin_c;
            //     var idx = this.getNullRobotIdx();
            //     if (!this.qiangcowRobotList_1[idx]) {
            //         var account = "robot" + idx;
            //         var userInfo = {account: account, robotMatch: false, idx: 0};
            //         var Robot = new qiangcowUser(userInfo);
            //         this.qiangcowRobotList_1[idx] = Robot;
            //         ++this.qiangcowRobotCount_1;
            //         ++this.qiangcowIdx;
            //         this.qiangcowIdx = this.qiangcowIdx % this.qiangcowIdxMax;
            //     }
            // }

            // //抢庄牛牛机器人    2
            // for (var item in this.qiangcowRobotList_2) {
            //     if (!this.qiangcowRobotList_2[item].isOnline()) {
            //         this.qiangcowRobotList_2[item].disconnect();
            //         delete this.qiangcowRobotList_2[item];
            //         --this.qiangcowRobotCount_2;
            //     }
            // }

            // if (this.qiangcowRobotCount_2 < 10) {
            //     this.qiangcowRobotMax = Math.floor(Math.random() * this.qiangcowRobotMax_c) + this.qiangcowRobotMin_c;
            //     var idx = this.getNullRobotIdx();
            //     if (!this.qiangcowRobotList_2[idx]) {
            //         var account = "robot" + idx;
            //         var userInfo = {account: account, robotMatch: false, idx: 1};
            //         var Robot = new qiangcowUser(userInfo);
            //         this.qiangcowRobotList_2[idx] = Robot;
            //         ++this.qiangcowRobotCount_2;
            //         ++this.qiangcowIdx;
            //         this.qiangcowIdx = this.qiangcowIdx % this.qiangcowIdxMax;
            //     }
            // }


            // //抢庄牛牛机器人    3
            // for (var item in this.qiangcowRobotList_3) {
            //     if (!this.qiangcowRobotList_3[item].isOnline()) {
            //         this.qiangcowRobotList_3[item].disconnect();
            //         delete this.qiangcowRobotList_3[item];
            //         --this.qiangcowRobotCount_3;
            //     }
            // }

            // if (this.qiangcowRobotCount_3 < 5) {
            //     this.qiangcowRobotMax = Math.floor(Math.random() * this.qiangcowRobotMax_c) + this.qiangcowRobotMin_c;
            //     var idx = this.getNullRobotIdx();
            //     if (!this.qiangcowRobotList_3[idx]) {
            //         var account = "robot" + idx;
            //         var userInfo = {account: account, robotMatch: false, idx: 2};
            //         var Robot = new qiangcowUser(userInfo);
            //         this.qiangcowRobotList_3[idx] = Robot;
            //         ++this.qiangcowRobotCount_3;
            //         ++this.qiangcowIdx;
            //         this.qiangcowIdx = this.qiangcowIdx % this.qiangcowIdxMax;
            //     }
            // }


            // //抢庄牛牛机器人    4
            // for (var item in this.qiangcowRobotList_4) {
            //     if (!this.qiangcowRobotList_4[item].isOnline()) {
            //         this.qiangcowRobotList_4[item].disconnect();
            //         delete this.qiangcowRobotList_4[item];
            //         --this.qiangcowRobotCount_4;
            //     }
            // }

            // if (this.qiangcowRobotCount_4 < 5) {
            //     this.qiangcowRobotMax = Math.floor(Math.random() * this.qiangcowRobotMax_c) + this.qiangcowRobotMin_c;
            //     var idx = this.getNullRobotIdx();
            //     if (!this.qiangcowRobotList_4[idx]) {
            //         var account = "robot" + idx;
            //         var userInfo = {account: account, robotMatch: false, idx: 3};
            //         var Robot = new qiangcowUser(userInfo);
            //         this.qiangcowRobotList_4[idx] = Robot;
            //         ++this.qiangcowRobotCount_4;
            //         ++this.qiangcowIdx;
            //         this.qiangcowIdx = this.qiangcowIdx % this.qiangcowIdxMax;
            //     }
            // }

            //斗地主机器人   1
            // for (var item in this.landlordRobotList_1) {
            //     if (!this.landlordRobotList_1[item].isOnline()) {
            //         this.landlordRobotList_1[item].disconnect();
            //         delete this.landlordRobotList_1[item];
            //         --this.landlordRobotCount_1;
            //     }
            // }

            // if (this.landlordRobotCount_1 < 10) {
            //     this.landlordRobotMax = Math.floor(Math.random() * this.landlordRobotMax_c) + this.landlordRobotMin_c;
            //     var idx = this.getNullRobotIdx();
            //     if (!this.landlordRobotList_1[idx]) {
            //         var account = "robot" + idx;
            //         var userInfo = {account: account, robotMatch: false, idx: 0};
            //         var Robot = new landlordUser(userInfo);
            //         this.landlordRobotList_1[idx] = Robot;
            //         ++this.landlordRobotCount_1;
            //     }
            // }
            //斗地主机器人   2
            // for (var item in this.landlordRobotList_2) {
            //     if (!this.landlordRobotList_2[item].isOnline()) {
            //         this.landlordRobotList_2[item].disconnect();
            //         delete this.landlordRobotList_2[item];
            //         --this.landlordRobotCount_2;
            //     }
            // }

            // if (this.landlordRobotCount_2 < 10) {
            //     this.landlordRobotMax = Math.floor(Math.random() * this.landlordRobotMax_c) + this.landlordRobotMin_c;
            //     var idx = this.getNullRobotIdx();
            //     if (!this.landlordRobotList_2[idx]) {
            //         var account = "robot" + idx;
            //         var userInfo = {account: account, robotMatch: false, idx: 1};
            //         var Robot = new landlordUser(userInfo);
            //         this.landlordRobotList_2[idx] = Robot;
            //         ++this.landlordRobotCount_2;
            //     }
            // }

            //斗地主机器人   3
            // for (var item in this.landlordRobotList_3) {
            //     if (!this.landlordRobotList_3[item].isOnline()) {
            //         this.landlordRobotList_3[item].disconnect();
            //         delete this.landlordRobotList_3[item];
            //         --this.landlordRobotCount_3;
            //     }
            // }

            // if (this.landlordRobotCount_3 < 5) {
            //     this.landlordRobotMax = Math.floor(Math.random() * this.landlordRobotMax_c) + this.landlordRobotMin_c;
            //     var idx = this.getNullRobotIdx();
            //     if (!this.landlordRobotList_3[idx]) {
            //         var account = "robot" + idx;
            //         var userInfo = {account: account, robotMatch: false, idx: 2};
            //         var Robot = new landlordUser(userInfo);
            //         this.landlordRobotList_3[idx] = Robot;
            //         ++this.landlordRobotCount_3;
            //     }
            // }

            //斗地主机器人   4
            // for (var item in this.landlordRobotList_4) {
            //     if (!this.landlordRobotList_4[item].isOnline()) {
            //         this.landlordRobotList_4[item].disconnect();
            //         delete this.landlordRobotList_4[item];
            //         --this.landlordRobotCount_4;
            //     }
            // }

            // if (this.landlordRobotCount_4 < 5) {
            //     this.landlordRobotMax = Math.floor(Math.random() * this.landlordRobotMax_c) + this.landlordRobotMin_c;
            //     var idx = this.getNullRobotIdx();
            //     if (!this.landlordRobotList_4[idx]) {
            //         var account = "robot" + idx;
            //         var userInfo = {account: account, robotMatch: false, idx: 3};
            //         var Robot = new landlordUser(userInfo);
            //         this.landlordRobotList_4[idx] = Robot;
            //         ++this.landlordRobotCount_4;
            //     }
            // }

            //龙虎斗机器人
            for (var item in this.longhuRobotList) {
                if (!this.longhuRobotList[item].isOnline()) {
                    this.longhuRobotList[item].disconnect();
                    delete this.longhuRobotList[item];
                    --this.longhuRobotCount;
                }
            }

            if (this.longhuRobotCount < this.longhuRobotMax) {
                this.longhuRobotMax = Math.floor(Math.random() * this.longhuRobotMax_c) + this.longhuRobotMin_c;
                var idx = this.getNullRobotIdx();
                if (!this.longhuRobotList[idx]) {
                    var account = "robot" + idx;
                    var userInfo = {account: account, robotMatch: false, idx: this.longhuIdx};
                    var Robot = new longhudouUser(userInfo);
                    this.longhuRobotList[idx] = Robot;
                    ++this.longhuRobotCount;
                    ++this.longhuIdx;
                    // this.longhuIdx = this.qiangcowIdx % this.qiangcowIdxMax;
                }
            }

            //百家乐机器人
            for (var item in this.baccaratRobotList) {
                if (!this.baccaratRobotList[item].isOnline()) {
                    this.baccaratRobotList[item].disconnect();
                    delete this.baccaratRobotList[item];
                    --this.baccaratRobotCount;
                }
            }

            if (this.baccaratRobotCount < this.baccaratRobotMax) {
                this.baccaratRobotMax = Math.floor(Math.random() * this.baccaratRobotMax_c) + this.baccaratRobotMin_c;
                var idx = this.getNullRobotIdx();
                if (!this.baccaratRobotList[idx]) {
                    var account = "robot" + idx;
                    var userInfo = {account: account, robotMatch: false, idx: this.baccaratIdx};
                    var Robot = new baccaratUser(userInfo);
                    this.baccaratRobotList[idx] = Robot;
                    ++this.baccaratRobotCount;
                    ++this.baccaratIdx;
                    // this.longhuIdx = this.qiangcowIdx % this.qiangcowIdxMax;
                }
            }
            //

            //百家乐抢庄机器人
            for (var item in this.baccaratQZRobotList) {
                if (!this.baccaratQZRobotList[item].isOnline()) {
                    this.baccaratQZRobotList[item].disconnect();
                    delete this.baccaratQZRobotList[item];
                    --this.baccaratQZRobotCount;
                }
            }

            if (this.baccaratQZRobotCount < this.baccaratQZRobotMax) {
                this.baccaratQZRobotMax = Math.floor(Math.random() * this.baccaratQZRobotMax_c) + this.baccaratQZRobotMin_c;
                var idx = this.getNullRobotIdx();
                if (!this.baccaratRobotList[idx]) {
                    var account = "robot" + idx;
                    var userInfo = {account: account, robotMatch: false, idx: this.baccaratQZIdx};
                    var Robot = new baccaratQZUser(userInfo);
                    this.baccaratQZRobotList[idx] = Robot;
                    ++this.baccaratQZRobotCount;
                    ++this.baccaratQZIdx;
                    // this.longhuIdx = this.qiangcowIdx % this.qiangcowIdxMax;
                }
            }
            
            //猜大小机器人
            // for (var item in this.caidaxiaoRobotList) {
            //     if (!this.caidaxiaoRobotList[item].isOnline()) {
            //         this.caidaxiaoRobotList[item].disconnect();
            //         delete this.caidaxiaoRobotList[item];
            //         --this.caidaxiaoRobotCount;
            //     }
            // }

            // if (this.caidaxiaoRobotCount < this.caidaxiaoRobotMax) {
            //     this.caidaxiaoRobotMax = Math.floor(Math.random() * this.caidaxiaoRobotMax_c) + this.caidaxiaoRobotMin_c;
            //     var idx = this.getNullRobotIdx();
            //     if (!this.caidaxiaoRobotList[idx]) {
            //         var account = "robot" + idx;
            //         var userInfo = {account: account, robotMatch: false, idx: this.caidaxiaoIdx};
            //         var Robot = new caidaxiaoUser(userInfo);
            //         this.caidaxiaoRobotList[idx] = Robot;
            //         ++this.caidaxiaoRobotCount;
            //         ++this.caidaxiaoIdx;
            //         // this.longhuIdx = this.qiangcowIdx % this.qiangcowIdxMax;
            //     }
            // }

            //百人牛牛
            // for (var item in this.bairenniuniuRobotList) {
            //     if (!this.bairenniuniuRobotList[item].isOnline()) {
            //         this.bairenniuniuRobotList[item].disconnect();
            //         delete this.bairenniuniuRobotList[item];
            //         --this.bairenniuniuRobotCount;
            //     }
            // }

            // if (this.bairenniuniuRobotCount < this.bairenniuniuRobotMax) {
            //     this.bairenniuniuRobotMax = Math.floor(Math.random() * this.bairenniuniuRobotMax_c) + this.bairenniuniuRobotMin_c;
            //     var idx = this.getNullRobotIdx();
            //     if (!this.bairenniuniuRobotList[idx]) {
            //         var account = "robot" + idx;
            //         var userInfo = {account: account, robotMatch: false, idx: this.bairenniuniuIdx};
            //         var Robot = new bairen_niuniuUser(userInfo);
            //         this.bairenniuniuRobotList[idx] = Robot;
            //         ++this.bairenniuniuRobotCount;
            //         ++this.bairenniuniuIdx;
            //         // this.longhuIdx = this.qiangcowIdx % this.qiangcowIdxMax;
            //     }
            // }

            //颜色方块机器人
            for (var item in this.ColorRobotList) {
                if (!this.ColorRobotList[item].isOnline()) {
                    this.ColorRobotList[item].disconnect();
                    delete this.ColorRobotList[item];
                    --this.ColorRobotCount;
                }
            }

            if (this.ColorRobotCount < this.ColorRobotMax) {
                this.ColorRobotMax = Math.floor(Math.random() * this.ColorRobotMax_c) + this.ColorRobotMin_c;
                var idx = this.getNullRobotIdx();
                if (!this.ColorRobotList[idx]) {
                    var account = "robot" + idx;
                    var userInfo = {account: account, robotMatch: false, idx: this.ColorIdx};
                    var Robot = new ColorUser(userInfo);
                    this.ColorRobotList[idx] = Robot;
                    ++this.ColorRobotCount;
                    ++this.ColorIdx;
                }
            }

            //飞禽走兽机器人
            for (var item in this.feiqinzoushouRobotList) {
                if (!this.feiqinzoushouRobotList[item].isOnline()) {
                    this.feiqinzoushouRobotList[item].disconnect();
                    delete this.feiqinzoushouRobotList[item];
                    --this.feiqinzoushouRobotCount;
                }
            }

            if (this.feiqinzoushouRobotCount < this.feiqinzoushouRobotMax) {
                this.feiqinzoushouRobotMax = Math.floor(Math.random() * this.feiqinzoushouRobotMax_c) + this.feiqinzoushouRobotMin_c;
                var idx = this.getNullRobotIdx();
                if (!this.feiqinzoushouRobotList[idx]) {
                    var account = "robot" + idx;
                    var userInfo = {account: account, robotMatch: false, idx: this.feiqinzoushouIdx};
                    var Robot = new feiqinzoushouUser(userInfo);
                    this.feiqinzoushouRobotList[idx] = Robot;
                    ++this.feiqinzoushouRobotCount;
                    ++this.feiqinzoushouIdx;
                }
            }

            //翻硬币机器人
            for (var item in this.fanyingbiRobotList) {
                if (!this.fanyingbiRobotList[item].isOnline()) {
                    this.fanyingbiRobotList[item].disconnect();
                    delete this.fanyingbiRobotList[item];
                    --this.fanyingbiRobotCount;
                }
            }

            if (this.fanyingbiRobotCount < this.fanyingbiRobotMax) {
                this.fanyingbiRobotMax = Math.floor(Math.random() * this.fanyingbiRobotMax_c) + this.fanyingbiRobotMin_c;
                var idx = this.getNullRobotIdx();
                if (!this.fanyingbiRobotList[idx]) {
                    var account = "robot" + idx;
                    var userInfo = {account: account, robotMatch: false, idx: this.fanyingbiIdx};
                    var Robot = new fanyingbiUser(userInfo);
                    this.fanyingbiRobotList[idx] = Robot;
                    ++this.fanyingbiRobotCount;
                    ++this.fanyingbiIdx;
                }
            }

            //红黑大战机器人
            // for (var item in this.hongheidazhanRobotList) {
            //     if (!this.hongheidazhanRobotList[item].isOnline()) {
            //         this.hongheidazhanRobotList[item].disconnect();
            //         delete this.hongheidazhanRobotList[item];
            //         --this.hongheidazhanRobotCount;
            //     }
            // }

            // if (this.hongheidazhanRobotCount < this.hongheidazhanRobotMax) {
            //     this.hongheidazhanRobotMax = Math.floor(Math.random() * this.hongheidazhanRobotMax_c) + this.hongheidazhanRobotMin_c;
            //     var idx = this.getNullRobotIdx();
            //     if (!this.hongheidazhanRobotList[idx]) {
            //         var account = "robot" + idx;
            //         var userInfo = {account: account, robotMatch: false, idx: this.hongheidazhanIdx};
            //         var Robot = new hongheidazhanUser(userInfo);
            //         this.hongheidazhanRobotList[idx] = Robot;
            //         ++this.hongheidazhanRobotCount;
            //         ++this.hongheidazhanIdx;
            //     }
            // }

            //斗牛机器人
            // for (var item in this.douniuRobotList) {
            //     if (!this.douniuRobotList[item].isOnline()) {
            //         this.douniuRobotList[item].disconnect();
            //         delete this.douniuRobotList[item];
            //         --this.douniuRobotCount;
            //     }
            // }

            // if (this.douniuRobotCount < this.douniuRobotMax) {
            //     this.douniuRobotMax = Math.floor(Math.random() * this.douniuRobotMax_c) + this.douniuRobotMin_c;
            //     var idx = this.getNullRobotIdx();
            //     if (!this.douniuRobotList[idx]) {
            //         var account = "robot" + idx;
            //         var userInfo = {account: account, robotMatch: false, idx: this.douniuIdx};
            //         var Robot = new douniuUser(userInfo);
            //         this.douniuRobotList[idx] = Robot;
            //         ++this.douniuRobotCount;
            //         ++this.douniuIdx;
            //     }
            // }

            //神兽机器人
            for (var item in this.shenshouRobotList) {
                if (!this.shenshouRobotList[item].isOnline()) {
                    this.shenshouRobotList[item].disconnect();
                    delete this.shenshouRobotList[item];
                    --this.shenshouRobotCount;
                }
            }

            if (this.shenshouRobotCount < this.shenshouRobotMax) {
                this.shenshouRobotMax = Math.floor(Math.random() * this.shenshouRobotMax_c) + this.shenshouRobotMin_c;
                var idx = this.getNullRobotIdx();
                if (!this.shenshouRobotList[idx]) {
                    var account = "robot" + idx;
                    var userInfo = {account: account, robotMatch: false, idx: this.shenshouIdx};
                    var Robot = new shenshouUser(userInfo);
                    this.shenshouRobotList[idx] = Robot;
                    ++this.shenshouRobotCount;
                    ++this.shenshouIdx;
                }
            }

            //7updown机器人
            for (var item in this.upDown7RobotList) {
                if (!this.upDown7RobotList[item].isOnline()) {
                    this.upDown7RobotList[item].disconnect();
                    delete this.upDown7RobotList[item];
                    --this.upDown7RobotCount;
                }
            }

            if (this.upDown7RobotCount < this.upDown7RobotMax) {
                this.upDown7RobotMax = Math.floor(Math.random() * this.upDown7RobotMax_c) + this.upDown7RobotMin_c;
                var idx = this.getNullRobotIdx();
                if (!this.upDown7RobotList[idx]) {
                    var account = "robot" + idx;
                    var userInfo = {account: account, robotMatch: false, idx: this.upDown7Idx};
                    var Robot = new UpDown7User(userInfo);
                    this.upDown7RobotList[idx] = Robot;
                    ++this.upDown7RobotCount;
                    ++this.upDown7Idx;
                }
            }

            //跑得快机器人   1
            // for (var item in this.runRobotList_1) {
            //     if (!this.runRobotList_1[item].isOnline()) {
            //         this.runRobotList_1[item].disconnect();
            //         delete this.runRobotList_1[item];
            //         --this.runRobotCount_1;
            //     }
            // }

            // if (this.runRobotCount_1 < 10) {
            //     this.runRobotMax = Math.floor(Math.random() * this.runRobotMax_c) + this.runRobotMin_c;
            //     var idx = this.getNullRobotIdx();
            //     if (!this.runRobotList_1[idx]) {
            //         var account = "robot" + idx;
            //         var userInfo = {account: account, robotMatch: false, idx: 0};
            //         var Robot = new runGame(userInfo);
            //         this.runRobotList_1[idx] = Robot;
            //         ++this.runRobotCount_1;
            //         // ++this.runIdx;
            //         // this.runIdx = this.runIdx % this.runIdxMax;
            //     }
            // }
            //跑得快机器人   2
            // for (var item in this.runRobotList_2) {
            //     if (!this.runRobotList_2[item].isOnline()) {
            //         this.runRobotList_2[item].disconnect();
            //         delete this.runRobotList_2[item];
            //         --this.runRobotCount_2;
            //     }
            // }

            // if (this.runRobotCount_2 < 10) {
            //     this.runRobotMax = Math.floor(Math.random() * this.runRobotMax_c) + this.runRobotMin_c;
            //     var idx = this.getNullRobotIdx();
            //     if (!this.runRobotList_2[idx]) {
            //         var account = "robot" + idx;
            //         var userInfo = {account: account, robotMatch: false, idx: 1};
            //         var Robot = new runGame(userInfo);
            //         this.runRobotList_2[idx] = Robot;
            //         ++this.runRobotCount_2;
            //         // ++this.runIdx;
            //         // this.runIdx = this.runIdx % this.runIdxMax;
            //     }
            // }

            //跑得快机器人   3
            // for (var item in this.runRobotList_3) {
            //     if (!this.runRobotList_3[item].isOnline()) {
            //         this.runRobotList_3[item].disconnect();
            //         delete this.runRobotList_3[item];
            //         --this.runRobotCount_3;
            //     }
            // }

            // if (this.runRobotCount_3 < 5) {
            //     this.runRobotMax = Math.floor(Math.random() * this.runRobotMax_c) + this.runRobotMin_c;
            //     var idx = this.getNullRobotIdx();
            //     if (!this.runRobotList_3[idx]) {
            //         var account = "robot" + idx;
            //         var userInfo = {account: account, robotMatch: false, idx: 2};
            //         var Robot = new runGame(userInfo);
            //         this.runRobotList_3[idx] = Robot;
            //         ++this.runRobotCount_3;
            //         // ++this.runIdx;
            //         // this.runIdx = this.runIdx % this.runIdxMax;
            //     }
            // }


            //跑得快机器人   4
            // for (var item in this.runRobotList_4) {
            //     if (!this.runRobotList_4[item].isOnline()) {
            //         this.runRobotList_4[item].disconnect();
            //         delete this.runRobotList_4[item];
            //         --this.runRobotCount_4;
            //     }
            // }

            // if (this.runRobotCount_4 < 5) {
            //     this.runRobotMax = Math.floor(Math.random() * this.runRobotMax_c) + this.runRobotMin_c;
            //     var idx = this.getNullRobotIdx();
            //     if (!this.runRobotList_4[idx]) {
            //         var account = "robot" + idx;
            //         var userInfo = {account: account, robotMatch: false, idx: 3};
            //         var Robot = new runGame(userInfo);
            //         this.runRobotList_4[idx] = Robot;
            //         ++this.runRobotCount_4;
            //         // ++this.runIdx;
            //         // this.runIdx = this.runIdx % this.runIdxMax;
            //     }
            // }

            //砸金花机器人   1
            // for (var item in this.goldenFowerRobotList_1) {
            //     if (!this.goldenFowerRobotList_1[item].isOnline()) {
            //         this.goldenFowerRobotList_1[item].disconnect();
            //         delete this.goldenFowerRobotList_1[item];
            //         --this.goldenFowerRobotCount_1;
            //     }
            // }

            // if (this.goldenFowerRobotCount_1 < 10) {
            //     this.goldenFowerRobotMax = Math.floor(Math.random() * this.goldenFowerRobotMax_c) + this.goldenFowerRobotMin_c;
            //     var idx = this.getNullRobotIdx();
            //     if (!this.goldenFowerRobotList_1[idx]) {
            //         var account = "robot" + idx;
            //         var userInfo = {account: account, robotMatch: false, idx: 0};
            //         var Robot = new GoldenFlower(userInfo);
            //         this.goldenFowerRobotList_1[idx] = Robot;
            //         ++this.goldenFowerRobotCount_1;
            //         ++this.goldenFowerIdx;
            //         this.goldenFowerIdx = this.goldenFowerIdx % this.goldenFowerIdxMax;
            //     }
            // }

            // //砸金花机器人    2
            // for (var item in this.goldenFowerRobotList_2) {
            //     if (!this.goldenFowerRobotList_2[item].isOnline()) {
            //         this.goldenFowerRobotList_2[item].disconnect();
            //         delete this.goldenFowerRobotList_2[item];
            //         --this.goldenFowerRobotCount_2;
            //     }
            // }

            // if (this.goldenFowerRobotCount_2 < 10) {
            //     this.goldenFowerRobotMax = Math.floor(Math.random() * this.goldenFowerRobotMax_c) + this.goldenFowerRobotMin_c;
            //     var idx = this.getNullRobotIdx();
            //     if (!this.goldenFowerRobotList_2[idx]) {
            //         var account = "robot" + idx;
            //         var userInfo = {account: account, robotMatch: false, idx: 1};
            //         var Robot = new GoldenFlower(userInfo);
            //         this.goldenFowerRobotList_2[idx] = Robot;
            //         ++this.goldenFowerRobotCount_2;
            //         ++this.goldenFowerIdx;
            //         this.goldenFowerIdx = this.goldenFowerIdx % this.goldenFowerIdxMax;
            //     }
            // }

            // //砸金花机器人    3
            // for (var item in this.goldenFowerRobotList_3) {
            //     if (!this.goldenFowerRobotList_3[item].isOnline()) {
            //         this.goldenFowerRobotList_3[item].disconnect();
            //         delete this.goldenFowerRobotList_3[item];
            //         --this.goldenFowerRobotCount_3;
            //     }
            // }

            // if (this.goldenFowerRobotCount_3 < 5) {
            //     this.goldenFowerRobotMax = Math.floor(Math.random() * this.goldenFowerRobotMax_c) + this.goldenFowerRobotMin_c;
            //     var idx = this.getNullRobotIdx();
            //     if (!this.goldenFowerRobotList_3[idx]) {
            //         var account = "robot" + idx;
            //         var userInfo = {account: account, robotMatch: false, idx: 2};
            //         var Robot = new GoldenFlower(userInfo);
            //         this.goldenFowerRobotList_3[idx] = Robot;
            //         ++this.goldenFowerRobotCount_3;
            //         ++this.goldenFowerIdx;
            //         this.goldenFowerIdx = this.goldenFowerIdx % this.goldenFowerIdxMax;
            //     }
            // }


            // //砸金花机器人    4
            // for (var item in this.goldenFowerRobotList_4) {
            //     if (!this.goldenFowerRobotList_4[item].isOnline()) {
            //         this.goldenFowerRobotList_4[item].disconnect();
            //         delete this.goldenFowerRobotList_4[item];
            //         --this.goldenFowerRobotCount_4;
            //     }
            // }

            // if (this.goldenFowerRobotCount_4 < 5) {
            //     this.goldenFowerRobotMax = Math.floor(Math.random() * this.goldenFowerRobotMax_c) + this.goldenFowerRobotMin_c;
            //     var idx = this.getNullRobotIdx();
            //     if (!this.goldenFowerRobotList_4[idx]) {
            //         var account = "robot" + idx;
            //         var userInfo = {account: account, robotMatch: false, idx: 3};
            //         var Robot = new GoldenFlower(userInfo);
            //         this.goldenFowerRobotList_4[idx] = Robot;
            //         ++this.goldenFowerRobotCount_4;
            //         ++this.goldenFowerIdx;
            //         this.goldenFowerIdx = this.goldenFowerIdx % this.goldenFowerIdxMax;
            //     }
            // }


            //德州机器人    1
            for (var item in this.holdemRobotList_1) {
                if (!this.holdemRobotList_1[item].isOnline()) {
                    this.holdemRobotList_1[item].disconnect();
                    delete this.holdemRobotList_1[item];
                    --this.holdemRobotCount_1;
                }
            }

            if (this.holdemRobotCount_1 < 10) {
                this.holdemRobotMax = Math.floor(Math.random() * this.holdemRobotMax_c) + this.holdemRobotMin_c;
                var idx = this.getNullRobotIdx();
                if (!this.holdemRobotList_1[idx]) {
                    var account = "robot" + idx;
                    var userInfo = {account: account, robotMatch: false, idx: 0};
                    var Robot = new Holdem(userInfo);
                    this.holdemRobotList_1[idx] = Robot;
                    ++this.holdemRobotCount_1;
                    ++this.holdemIdx;
                    this.holdemIdx = this.holdemIdx % this.holdemIdxMax;
                }
            }

            //德州机器人   2
            for (var item in this.holdemRobotList_2) {
                if (!this.holdemRobotList_2[item].isOnline()) {
                    this.holdemRobotList_2[item].disconnect();
                    delete this.holdemRobotList_2[item];
                    --this.holdemRobotCount_2;
                }
            }

            if (this.holdemRobotCount_2 < 10) {
                this.holdemRobotMax = Math.floor(Math.random() * this.holdemRobotMax_c) + this.holdemRobotMin_c;
                var idx = this.getNullRobotIdx();
                if (!this.holdemRobotList_2[idx]) {
                    var account = "robot" + idx;
                    var userInfo = {account: account, robotMatch: false, idx: 1};
                    var Robot = new Holdem(userInfo);
                    this.holdemRobotList_2[idx] = Robot;
                    ++this.holdemRobotCount_2;
                    ++this.holdemIdx;
                    this.holdemIdx = this.holdemIdx % this.holdemIdxMax;
                }
            }


            //德州机器人   3
            for (var item in this.holdemRobotList_3) {
                if (!this.holdemRobotList_3[item].isOnline()) {
                    this.holdemRobotList_3[item].disconnect();
                    delete this.holdemRobotList_3[item];
                    --this.holdemRobotCount_3;
                }
            }

            if (this.holdemRobotCount_3 < 5) {
                this.holdemRobotMax = Math.floor(Math.random() * this.holdemRobotMax_c) + this.holdemRobotMin_c;
                var idx = this.getNullRobotIdx();
                if (!this.holdemRobotList_3[idx]) {
                    var account = "robot" + idx;
                    var userInfo = {account: account, robotMatch: false, idx: 2};
                    var Robot = new Holdem(userInfo);
                    this.holdemRobotList_3[idx] = Robot;
                    ++this.holdemRobotCount_3;
                    ++this.holdemIdx;
                    this.holdemIdx = this.holdemIdx % this.holdemIdxMax;
                }
            }


            //德州机器人   4
            for (var item in this.holdemRobotList_4) {
                if (!this.holdemRobotList_4[item].isOnline()) {
                    this.holdemRobotList_4[item].disconnect();
                    delete this.holdemRobotList_4[item];
                    --this.holdemRobotCount_4;
                }
            }

            if (this.holdemRobotCount_4 < 5) {
                this.holdemRobotMax = Math.floor(Math.random() * this.holdemRobotMax_c) + this.holdemRobotMin_c;
                var idx = this.getNullRobotIdx();
                if (!this.holdemRobotList_4[idx]) {
                    var account = "robot" + idx;
                    var userInfo = {account: account, robotMatch: false, idx: 3};
                    var Robot = new Holdem(userInfo);
                    this.holdemRobotList_4[idx] = Robot;
                    ++this.holdemRobotCount_4;
                    ++this.holdemIdx;
                    this.holdemIdx = this.holdemIdx % this.holdemIdxMax;
                }
            }

            //奔驰宝马机器人
            for (var item in this.bcbmRobotList) {
                if (!this.bcbmRobotList[item].isOnline()) {
                    this.bcbmRobotList[item].disconnect();
                    delete this.bcbmRobotList[item];
                    --this.bcbmRobotCount;
                }
            }

            if (this.bcbmRobotCount < this.bcbmRobotMax) {
                this.bcbmRobotMax = Math.floor(Math.random() * this.bcbmRobotMax_c) + this.bcbmRobotMin_c;
                var idx = this.getNullRobotIdx();
                if (!this.bcbmRobotList[idx]) {
                    var account = "robot" + idx;
                    var userInfo = {account: account, robotMatch: false, idx: this.caidaxiaoIdx};
                    var Robot = new bcbmUser(userInfo);
                    this.bcbmRobotList[idx] = Robot;
                    ++this.bcbmRobotCount;
                    ++this.bcbmIdx;
                    // this.longhuIdx = this.qiangcowIdx % this.qiangcowIdxMax;
                }
            }
			
			//铁拳6机器人
            // for (var item in this.tiequan6RobotList) {
            //     if (!this.tiequan6RobotList[item].isOnline()) {
            //         this.tiequan6RobotList[item].disconnect();
            //         delete this.tiequan6RobotList[item];
            //         --this.tiequan6RobotCount;
            //     }
            // }

            // if (this.tiequan6RobotCount < this.tiequan6RobotMax) {
            //     this.tiequan6RobotMax = Math.floor(Math.random() * this.tiequan6RobotMax_c) + this.tiequan6RobotMin_c;
            //     var idx = this.getNullRobotIdx();
            //     if (!this.tiequan6RobotList[idx]) {
            //         var account = "robot" + idx;
            //         var userInfo = {account: account, robotMatch: false, idx: this.caidaxiaoIdx};
            //         var Robot = new tiequan6User(userInfo);
            //         this.tiequan6RobotList[idx] = Robot;
            //         ++this.tiequan6RobotCount;
            //         ++this.tiequan6Idx;
            //         // this.longhuIdx = this.qiangcowIdx % this.qiangcowIdxMax;
            //     }
            // }

            //德州牛仔机器人
            // for (var item in this.dznzRobotList) {
            //     if (!this.dznzRobotList[item].isOnline()) {
            //         this.dznzRobotList[item].disconnect();
            //         delete this.dznzRobotList[item];
            //         --this.dznzRobotCount;
            //     }
            // }

            // if (this.dznzRobotCount < this.dznzRobotMax) {
            //     this.dznzRobotMax = Math.floor(Math.random() * this.dznzRobotMax_c) + this.dznzRobotMin_c;
            //     var idx = this.getNullRobotIdx();
            //     if (!this.dznzRobotList[idx]) {
            //         var account = "robot" + idx;
            //         var userInfo = {account: account, robotMatch: false, idx: this.dznzIdx};
            //         var Robot = new dznzUser(userInfo);
            //         this.dznzRobotList[idx] = Robot;
            //         ++this.dznzRobotCount;
            //         ++this.dznzIdx;
            //     }
            // }

            //28杠机器人
            // for (var item in this.Game28RobotList) {
            //     if (!this.Game28RobotList[item].isOnline()) {
            //         this.Game28RobotList[item].disconnect();
            //         delete this.Game28RobotList[item];
            //         --this.Game28RobotCount;
            //     }
            // }

            // if (this.Game28RobotCount < this.Game28RobotMax) {
            //     this.Game28RobotMax = Math.floor(Math.random() * this.Game28RobotMax_c) + this.Game28RobotMin_c;
            //     var idx = this.getNullRobotIdx();
            //     if (!this.Game28RobotList[idx]) {
            //         var account = "robot" + idx;
            //         var userInfo = {account: account, robotMatch: false, idx: this.Game28Idx};
            //         var Robot = new ttzUser(userInfo);
            //         this.Game28RobotList[idx] = Robot;
            //         ++this.Game28RobotCount;
            //         ++this.Game28Idx;
            //     }
            // }

        };


        //获得一个空的机器人ID
        this.getNullRobotIdx = function () {
            var idx = RandomNumBoth(1, 10000);
            var flag = true;
            while (flag) {
                if (this.MatchFishRobotList[idx]) {
                    idx = RandomNumBoth(1, 10000);
                    continue;
                }
                if (this.FishRobotList[idx]) {
                    idx = RandomNumBoth(1, 10000);
                    continue;
                }
                if (this.Game28RobotList[idx]) {
                    idx = RandomNumBoth(1, 10000);
                    continue;
                }
                if (this.redbagRobotList[idx]) {
                    idx = RandomNumBoth(1, 10000);
                    continue;
                }
                if (this.jia82RobotList[idx]) {
                    idx = RandomNumBoth(1, 10000);
                    continue;
                }
                // if (this.cowRobotList[idx]) {
                //     idx = RandomNumBoth(1, 10000);
                //     continue;
                // }
                // if (this.qiangcowRobotList_1[idx]) {
                //     idx = RandomNumBoth(1, 10000);
                //     continue;
                // }
                // if (this.qiangcowRobotList_2[idx]) {
                //     idx = RandomNumBoth(1, 10000);
                //     continue;
                // }
                // if (this.qiangcowRobotList_3[idx]) {
                //     idx = RandomNumBoth(1, 10000);
                //     continue;
                // }
                // if (this.qiangcowRobotList_4[idx]) {
                //     idx = RandomNumBoth(1, 10000);
                //     continue;
                // }
                // if (this.jingdiancowRobotList[idx]) {
                //     idx = RandomNumBoth(1, 10000);
                //     continue;
                // }
                // if (this.landlordRobotList_1[idx]) {
                //     idx = RandomNumBoth(1, 10000);
                //     continue;
                // }
                // if (this.landlordRobotList_2[idx]) {
                //     idx = RandomNumBoth(1, 10000);
                //     continue;
                // }
                // if (this.landlordRobotList_3[idx]) {
                //     idx = RandomNumBoth(1, 10000);
                //     continue;
                // }
                // if (this.landlordRobotList_4[idx]) {
                //     idx = RandomNumBoth(1, 10000);
                //     continue;
                // }
                if (this.longhuRobotList[idx]) {
                    idx = RandomNumBoth(1, 10000);
                    continue;
                }
                if (this.baccaratRobotList[idx]) {
                    idx = RandomNumBoth(1, 10000);
                    continue;
                }
                if (this.baccaratQZRobotList[idx]) {
                    idx = RandomNumBoth(1, 10000);
                    continue;
                }
                if (this.caidaxiaoRobotList[idx]) {
                    idx = RandomNumBoth(1, 10000);
                    continue;
                }
                if (this.bairenniuniuRobotList[idx]) {
                    idx = RandomNumBoth(1, 10000);
                    continue;
                }
                if (this.runRobotList_1[idx]) {
                    idx = RandomNumBoth(1, 10000);
                    continue;
                }
                if (this.runRobotList_2[idx]) {
                    idx = RandomNumBoth(1, 10000);
                    continue;
                }
                if (this.runRobotList_3[idx]) {
                    idx = RandomNumBoth(1, 10000);
                    continue;
                }
                if (this.runRobotList_4[idx]) {
                    idx = RandomNumBoth(1, 10000);
                    continue;
                }
                if (this.goldenFowerRobotList_1[idx]) {
                    idx = RandomNumBoth(1, 10000);
                    continue;
                }
                if (this.goldenFowerRobotList_2[idx]) {
                    idx = RandomNumBoth(1, 10000);
                    continue;
                }
                if (this.goldenFowerRobotList_3[idx]) {
                    idx = RandomNumBoth(1, 10000);
                    continue;
                }
                if (this.goldenFowerRobotList_4[idx]) {
                    idx = RandomNumBoth(1, 10000);
                    continue;
                }

                if (this.holdemRobotList_1[idx]) {
                    idx = RandomNumBoth(1, 10000);
                    continue;
                }
                if (this.holdemRobotList_2[idx]) {
                    idx = RandomNumBoth(1, 10000);
                    continue;
                }
                if (this.holdemRobotList_3[idx]) {
                    idx = RandomNumBoth(1, 10000);
                    continue;
                }
                if (this.holdemRobotList_4[idx]) {
                    idx = RandomNumBoth(1, 10000);
                    continue;
                }
                if (this.bcbmRobotList[idx]) {
                    idx = RandomNumBoth(1, 10000);
                    continue;
                }
				if (this.tiequan6RobotList[idx]) {
                    idx = RandomNumBoth(1, 10000);
                    continue;
                }
                if (this.dznzRobotList[idx]) {
                    idx = RandomNumBoth(1, 10000);
                    continue;
                }
                flag = false;
            }
            return idx;
        };
//-------------------------------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------------------

        //获得用户
        this.runGameAddUser = function (u_idx) {
            if (this.runRobotCount < this.runRobotMax) {
                var idx = this.getNullRobotIdx();
                if (!this.runRobotList_1[idx]) {
                    var account = "robot" + idx;
                    var userInfo = {account: account, robotMatch: false, idx: u_idx};
                    var R = new runGame(userInfo);
                    this.runRobotList_1[idx] = R;
                    ++this.runRobotCount;
                }
            }
        };

        this.landlordAddUser = function (u_idx) {
            if (this.landlordRobotCount < this.landlordRobotMax) {
                this.landlordRobotMax = Math.floor(Math.random() * this.landlordRobotMax_c) + this.landlordRobotMin_c;
                var idx = this.getNullRobotIdx();
                if (!this.landlordRobotList[idx]) {
                    var account = "robot" + idx;
                    var userInfo = {account: account, robotMatch: false, idx: u_idx};
                    var R = new landlordUser(userInfo);
                    this.landlordRobotList[idx] = R;
                    ++this.landlordRobotCount;

                }
            }
        };

        this.Setmaintain = function () {
            gameConfig.maintain = true;
        };

        this.isMaintain = function () {
            return gameConfig.maintain;
        }
        //运行初始化
        //this.init();
    };


    if (_gameinfo) {
        return {getInstand: _gameinfo}
    } else {
        log.info("####create game!####");
        _gameinfo = new Game();
        return {getInstand: _gameinfo}
    }

}();


module.exports = robotInfo;


function init_table_key() {
    var key = "";
    for (var i = 0; i < 7; i++) {
        key += RandomNumBoth(0, 9)
    }
    return key
}

function RandomNumBoth(Min, Max) {
    //生成指定范围内随机整数
    var Range = Max - Min;
    var Rand = Math.random();
    var num = Min + Math.round(Rand * Range); //四舍五入
    return num;
}


function RandomNumForList(arr) {
    //从指定数组中选取随机值
    return arr[Math.floor((Math.random() * arr.length))]
}